package com.estate.struts.actions;

import java.util.Date;
import java.util.List;

import org.apache.struts2.ServletActionContext;

import com.estate.business.PriceProjectService;
import com.estate.business.UserInfoService;
import com.estate.utils.StageUtil;
import com.estate.vo.Vo;
import com.estate.vo.impl.PriceProjectVo;
import com.estate.vo.impl.UserInfoVo;

public class EngineeringReviewAction extends EstateSupport {

	private PriceProjectService priceProjectService;
	private UserInfoService userInfoService;
	
	private String method;
	private String multiType;
	
	private int id;
	private String number;                             //项目编号
	private String name;                               //项目名称
	private String delegateCompany;                    //委托单位 
	private String delegateUser;                       //委托单位联系人
	private String delegatePhone;                      //委托单位联系人电话
	private String proCatagory;                        //工作项目类别
	private Date receiveDate;                          //收到日期
	private int contractId;                            //合同ID
	private String estimatePrice;                      //合同估算价
	private String submitPrice;                        //送审价
	private String proRegion;                          //所属地区
	private String industryCatagory;                   //行业分类
	private int submitUserId;                          //填写人
	private String remark;                             //备注
	private String proName;                            //单项工程名称
	private String proCompany;                         //建设单位名称
	private String proContact;                         //建设单位联系人
	private String proContactPhone;                    //建设单位联系人电话
	private String workCatagory;                       //工作项目分类
	private int stage;                                 //阶段
	private Date authorDate;                           //下发日期
	private int submit;                                //是否已上报
	private int recordUserId;                          //咨询人员ID
	private UserInfoVo contactUser;
	
	public String execute() throws Exception{
		
		String page="";
		if("list".equals(method)){
			System.out.println("run success");
			List<PriceProjectVo> engineeringReviewList=priceProjectService.findByStage(4);
			for(int i=5;i<=12;i++){
				engineeringReviewList.addAll(priceProjectService.findByStage(i));
			}
			for(int i=0;i<engineeringReviewList.size();i++){
				if(engineeringReviewList.get(i).getStage()>5){
					engineeringReviewList.get(i).setStageName(StageUtil.getStageString(6));
				}else{
					engineeringReviewList.get(i).setStageName(StageUtil.getStageString(5));
				}
			}
			System.out.println(this.getMultiType());
			if(this.getMultiType() != null && this.getMultiType().equals("true")){
				this.getRequest().setAttribute("multiType", new Boolean(true));
//				System.out.println("set multiType "+ this.getRequest().getAttribute("multiType"));
			}else{
				this.getRequest().setAttribute("multiType", new Boolean(false));
//				System.out.println("set singleType "+ this.getRequest().getAttribute("multiType"));
			}
			ServletActionContext.getRequest().setAttribute("engineeringReview", engineeringReviewList);
			page="list";
		}
		return page;
	}
	
	public void setPriceProjectService(PriceProjectService priceProjectService) {
		this.priceProjectService = priceProjectService;
	}

	public PriceProjectService getPriceProjectService() {
		return priceProjectService;
	}

	public void setUserInfoService(UserInfoService userInfoService) {
		this.userInfoService = userInfoService;
	}

	public UserInfoService getUserInfoService() {
		return userInfoService;
	}
	
	public void setId(int id) {
		this.id = id;
	}

	public int getId() {
		return id;
	}

	public void setNumber(String number) {
		this.number = number;
	}

	public String getNumber() {
		return number;
	}

	public void setName(String name) {
		this.name = name;
	}

	public String getName() {
		return name;
	}

	public void setDelegateCompany(String delegateCompany) {
		this.delegateCompany = delegateCompany;
	}

	public String getDelegateCompany() {
		return delegateCompany;
	}

	public void setDelegateUser(String delegateUser) {
		this.delegateUser = delegateUser;
	}

	public String getDelegateUser() {
		return delegateUser;
	}

	public void setDelegatePhone(String delegatePhone) {
		this.delegatePhone = delegatePhone;
	}

	public String getDelegatePhone() {
		return delegatePhone;
	}

	public void setProCatagory(String proCatagory) {
		this.proCatagory = proCatagory;
	}

	public String getProCatagory() {
		return proCatagory;
	}

	public void setReceiveDate(Date receiveDate) {
		this.receiveDate = receiveDate;
	}

	public Date getReceiveDate() {
		return receiveDate;
	}

	public void setContractId(int contractId) {
		this.contractId = contractId;
	}

	public int getContractId() {
		return contractId;
	}

	public void setEstimatePrice(String estimatePrice) {
		this.estimatePrice = estimatePrice;
	}

	public String getEstimatePrice() {
		return estimatePrice;
	}

	public void setSubmitPrice(String submitPrice) {
		this.submitPrice = submitPrice;
	}

	public String getSubmitPrice() {
		return submitPrice;
	}

	public void setProRegion(String proRegion) {
		this.proRegion = proRegion;
	}

	public String getProRegion() {
		return proRegion;
	}

	public void setIndustryCatagory(String industryCatagory) {
		this.industryCatagory = industryCatagory;
	}

	public String getIndustryCatagory() {
		return industryCatagory;
	}

	public void setSubmitUserId(int submitUserId) {
		this.submitUserId = submitUserId;
	}

	public int getSubmitUserId() {
		return submitUserId;
	}

	public void setRemark(String remark) {
		this.remark = remark;
	}

	public String getRemark() {
		return remark;
	}

	public void setProName(String proName) {
		this.proName = proName;
	}

	public String getProName() {
		return proName;
	}

	public void setProCompany(String proCompany) {
		this.proCompany = proCompany;
	}

	public String getProCompany() {
		return proCompany;
	}

	public void setProContact(String proContact) {
		this.proContact = proContact;
	}

	public String getProContact() {
		return proContact;
	}

	public void setProContactPhone(String proContactPhone) {
		this.proContactPhone = proContactPhone;
	}

	public String getProContactPhone() {
		return proContactPhone;
	}

	public void setWorkCatagory(String workCatagory) {
		this.workCatagory = workCatagory;
	}

	public String getWorkCatagory() {
		return workCatagory;
	}

	public void setStage(int stage) {
		this.stage = stage;
	}

	public int getStage() {
		return stage;
	}

	public void setAuthorDate(Date authorDate) {
		this.authorDate = authorDate;
	}

	public Date getAuthorDate() {
		return authorDate;
	}

	public void setSubmit(int submit) {
		this.submit = submit;
	}

	public int getSubmit() {
		return submit;
	}

	public void setRecordUserId(int recordUserId) {
		this.recordUserId = recordUserId;
	}

	public int getRecordUserId() {
		return recordUserId;
	}
	
	public String getMethod(){
		return method;
	}
	
	public void setMethod(String method){
		this.method=method;
	}

	public void setContactUser(UserInfoVo contactUser) {
		this.contactUser = contactUser;
	}

	public UserInfoVo getContactUser() {
		return contactUser;
	}

	public void setMultiType(String multiType) {
		this.multiType = multiType;
	}

	public String getMultiType() {
		return multiType;
	}
}
